//fork函数测试
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include <unistd.h>





int main(int argc,char* argv[])
{
	//创建子进程
	//pid_t fork(void);
	pid_t pid = fork();
	if(pid<0)//fork失败的情况
	{
		perror("fork error");
		return -1;
	}
	else if(pid > 0)
	{
		sleep(1);
		printf("father,pid = [%d],ppid = [%d]\n",getpid(),getppid());
	}
	else if(pid == 0)
	{	
		printf("child,pid = [%d],ppid = [%d]\n",getpid(),getppid());
		execl("./test01","test01","Hello","World","Ni","Hao",NULL);
		//execlp("ls","ls","-l",NULL);
		perror("excel error");
	}
	return 0;
}
